You are here: Statements and Functions > Contents()
Syntax samples
CONTENTS(<location>{,<entity type>})
LOAD CONTENTS(Loc1)
JOIN CONTENTS(Loc1, EntA) EntA
Returns either the total number of entities at a location or the number of a certain type of entity at a location. Use CONTENTS() to make decisions based on how busy a location is. Using CONTENTS() to keep track of the number of entities at a location requires fewer steps and allows more flexibility than using variables to count the number of entities that enter and exit a location. For example, the second syntax does in one statement what would require several statements without the CONTENTS() function.
Any logic and all fields except those fields evaluated at translation only. For a list of the fields evaluated only at translation, see the Appendix A.
Components
<location>
The name of the location to examine.
<entity type>
The optional name of the type of entity to look for. If omitted, CONTENTS() will return the total of all entities at the location.
Example
An assembly line has a location called Clean that often gets too busy for one operator to handle and the supervisor then comes to help. The processing logic below models this situation with an IF...THEN statement and the CONTENTS() function. As long as the location contains fewer than five entities, a worker processes any arriving entities. However, if the location’s contents are greater than five, the Supervisor processes them.
Process Table
Entity |
Location |
Operation (min) |
---|---|---|
ALL |
Clean |
IF CONTENTS(Clean)<5 THEN USE Worker FOR 10 ELSE USE Worker FOR 10 OR Supervisor FOR 10 |
Routing Table
Blk |
Output |
Destination |
Rule |
Move Logic |
---|---|---|---|---|
1 |
ALL |
Mold |
FIRST 1 |
MOVE FOR 1 |
FREECAP(), LOC(), ENT(), and FREEUNITS().